package com.nas.crocus.controller;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nas.crocus.domain.Alojamiento;
import com.nas.crocus.service.AlojamientoService;


@Controller
public class AlojamientoController {
    
    @Autowired
    private AlojamientoService alojamientoService;
    
    @RequestMapping(value="/evento/id/{id}/alojamiento", method = RequestMethod.GET)
    public @ResponseBody Collection<Alojamiento> buscarAlojamientoPorEvento(@PathVariable Long id) {
        Collection<Alojamiento> alojamientos = alojamientoService.buscarPorEventoId(id);
        for (Alojamiento alojamiento : alojamientos) {
            alojamiento.setEvento(null);
            alojamiento.getHotel().setAlojamientos(new  ArrayList<Alojamiento>());
        }
        
        return alojamientos;
    }
   
}
